﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.DbHelper.BaseHelper;
using Common.DbHelper;
using Common.DbHelper.HelperException;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Data.Common;

namespace Common.DbHelper.Helper
{
    /// <summary>
    /// 作者：赵虎
    /// 时间：2010-1-31
    /// 功能：MSSQL基础处理类
    /// </summary>
    public class MsSqlDataHelper : DataHelp, IHelp
    {
        /// <summary>
        /// MSSQL数据库
        /// </summary>
        public MsSqlDataHelper(string connString)
        {
            try
            {
                this.Connection = new SqlConnection(connString);
                this.Command = new SqlCommand();
                this.Adapter = new SqlDataAdapter();
            }
            catch (Exception e)
            {
                DbHelpException ex = new DbHelpException();
                ex.ConnectionString = this.ConnectionString;
                ex.Exception = e;
                OnException(ex);
            }
        }

        /// <summary>
        /// 通用的异常处理
        /// </summary>
        /// <param name="e">当前的异常信息</param>
        protected override void OnException(DbHelpException e)
        {
            throw e.Exception;
        }
    }
}